//
//  SecondViewController.m
//  中关村在线
//
//  Created by dllo on 16/1/11.
//  Copyright © 2016年 guoguo. All rights reserved.
//

#import "SecondViewController.h"
#import "News.h"
@interface SecondViewController ()<UIWebViewDelegate>

@property (nonatomic, retain) UIWebView *web;
@property (nonatomic,retain) UIView *view1;
@property (nonatomic, retain) UIActivityIndicatorView *activity;


@end

@implementation SecondViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)dealloc{
    [super dealloc];
    [_model release];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.navigationItem.title = @"果果";
    
    
    self.view.backgroundColor = [UIColor redColor];
    
   
    
    self.web = [[UIWebView alloc] initWithFrame:self.view.bounds];
    
    [self.view addSubview:_web];
    _web.delegate = self;
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        [_web loadRequest:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:_model.url]]];
    });
    
    
      [self initViewAndActivity];
    
    
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView{
    
    
    NSLog(@"fsdfasdfa4sdfa54sdf3asd4f8777777777777777777777");
  
    
    [_activity startAnimating];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView{
    
    
    NSLog(@"546545646545a4ds5f4a65sd4f6a5sdf");
    [_activity stopAnimating];
    [_view1 removeFromSuperview];
    
    
}


- (void)initViewAndActivity{
    
    self.view1 = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    _view1.backgroundColor = [UIColor blackColor];
    _view1.alpha = 0.5;
    
    [self.view addSubview:_view1];
    
    [_view1 release];
    
    
    self.activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    _activity.center = _view1.center;
    _activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite;
    
    [_view1 addSubview:_activity];
    
    
    [_activity release];
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
